import axios from '@/utils/axios';

export const getSitePage = (params) => {
    return axios.request({
        url: '/site/page',
        method: 'get',
        params
    });
};

export const getStaffPage = (params) => {
    return axios.request({
        url: '/site/staff/page',
        method: 'get',
        params
    });
};

export const getSite = (id) => {
    return axios.request({
        url: '/site/' + id,
        method: 'get'
    });
};

export const updateSite = (data) => {
    return axios.request({
        url: '/site/' + data.id,
        data,
        method: 'put'
    });
};

export const addSite = (data) => {
    return axios.request({
        url: '/site',
        data,
        method: 'post'
    });
};

export const getAdminSiteList = () => {
    return axios.request({
        url: '/site/admin-list',
        method: 'get'
    });
};

export const copySite = (data) => {
    return axios.request({
        url: '/site/copy',
        data,
        method: 'post'
    });
};

export const getMenuTree = () => {
    return axios.request({
        url: '/menu/tree',
        method: 'get'
    });
};

export const addStaff = (data) => {
    return axios.request({
        url: '/staff',
        data,
        method: 'post'
    });
};

export const inviteStaff = (data) => {
    return axios.request({
        url: '/staff/invite',
        data,
        method: 'post'
    });
};

export const getStaff = (id) => {
    return axios.request({
        url: '/staff/' + id,
        method: 'get'
    });
};

export const updateStaff = (data) => {
    return axios.request({
        url: '/staff/' + data.id,
        data,
        method: 'put'
    });
};

export const deleteStaff = (id) => {
    return axios.request({
        url: '/staff/' + id,
        method: 'delete'
    });
};

export const getFreightTree = (params) => {
    return axios.request({
        url: '/site/freight/tree',
        method: 'get',
        params
    });
};

export const getFreightList = (params) => {
    return axios.request({
        url: '/site/freight/list',
        method: 'get',
        params
    });
};

export const addFreight = (data) => {
    return axios.request({
        url: '/site/freight',
        data,
        method: 'post'
    });
};

export const deleteFreight = (id) => {
    return axios.request({
        url: '/site/freight/' + id,
        method: 'delete'
    });
};

export const getFreight = (id) => {
    return axios.request({
        url: '/site/freight/' + id,
        method: 'get'
    });
};

export const updateFreight = (data) => {
    return axios.request({
        url: '/site/freight/' + data.id,
        data,
        method: 'put'
    });
};

// 新增搜索热词
export const addHotKeyWords = (data) => {
    return axios.request({
        url: '/site/keyword/',
        data,
        method: 'post'
    });
};

// 分页获取热词列表
export const getHotKeyWordsList = (params) => {
    return axios.request({
        url: '/site/keyword/page',
        method: 'get',
        params
    });
};

// 编辑关键词
export const updateHotKeyWords = (data) => {
    return axios.request({
        url: '/site/keyword/edit',
        data,
        method: 'put'
    });
};

// 编辑关键词状态
export const updateHotKeyWordsStatus = (data) => {
    return axios.request({
        url: '/site/keyword/editKeywordState',
        data,
        method: 'put'
    });
};

// 删除关键词
export const deleteHotKeyWords = (siteId, keywordId) => {
    return axios.request({
        url: `/site/keyword/${siteId}/${keywordId}`,
        method: 'delete'
    });
};

export const getSiteTaxPage = (params) => {
    return axios.request({
        url: '/site/tax/page',
        method: 'get',
        params
    });
};

export const updateSiteTax = (data) => {
    return axios.request({
        url: '/site/tax/' + data.id,
        data,
        method: 'put'
    });
};
